/**
 * ===========================================================================
 * 版权所有 湖南免了么网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.mianle.me
 * ===========================================================================
 * 15:16 2018/6/5
 */
package com.mianle.userapi.controller;

import com.mianle.userapi.service.RongService;
import io.rong.RongCloud;
import io.rong.models.response.TokenResult;
import io.rong.models.user.UserModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: yiyuan
 * @Description:
 * @Date: Created in 15:16 2018/6/5
 *
 */
@RestController
@RequestMapping("rong")
public class RongController {

    @Autowired
    private RongService rongService;

    @Autowired
    private RongCloud rongCloud;


    @GetMapping("register")
    public TokenResult register(@RequestParam(value = "id", required = false) String id, @RequestParam(value = "name", required = false) String name,
                                @RequestParam(value = "portrait", required = false) String portrait)throws Exception {
        // 获取 Token 方法
        UserModel userModel = new UserModel()
                .setId("userId123")
                .setName("username123")
                .setPortrait("http://www.rongcloud.cn/images/logo.png");
        TokenResult tokenResult = rongCloud.user.register(userModel);
        System.out.println("getToken:  " + tokenResult.toString());
        return tokenResult;
    }
}
